package logic

import (
	"context"
	"doc-register/model"

	"doc-register/userrpc/internal/svc"
	"doc-register/userrpc/userrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type DocDetailLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDocDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DocDetailLogic {
	return &DocDetailLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *DocDetailLogic) DocDetail(in *userrpc.DocDetailRequest) (*userrpc.DocDetailResponse, error) {
	// todo: add your logic here and delete this line
	var doc model.Doc
	model.DB.Where("docs.id=?", in.DocId).First(&doc)
	return &userrpc.DocDetailResponse{
		DocId:   int64(doc.ID),
		Name:    doc.Name,
		Title:   doc.Title,
		Types:   doc.Types,
		CarNum:  doc.CarNum,
		Number:  doc.Number,
		VxName:  doc.VxName,
		Phone:   doc.Phone,
		Address: doc.Address,
	}, nil
}
